/**
 * @file
 * @author  Tsin Smith <tsin.creator@gmail.com>
 *
 * @section DESCRIPTION
 *
 */

#ifndef __TSIN_RUNTIME_BULLETRUNTIME_H__
#define __TSIN_RUNTIME_BULLETRUNTIME_H__

#include <tsin/runtime/common.hpp>
#include <tsin/display/DisplayObject.hpp>
#include <tsin/library/BuiltinImages.hpp>

namespace tsin {

        class BulletEvent;
        enum ImageSeriesId;
        enum BulletShape;
        enum BulletColor;

        static const int MAX_ACTIVE_EVENTS = 10;
        static const int MAX_EVENTS_IN_POOL = 20;

        enum BulletLifeStage {
                BULLET_STAGE_UTERO = 0,
                BULLET_STAGE_BEFALL,
                BULLET_STAGE_LIVE,
                BULLET_STAGE_VANISHING,
                BULLET_STAGE_DIED
        };

        class RUNTIME_DLLEXPORT BulletRuntime : public DisplayObject
        {
        public:
                BulletLifeStage stage;
                ImageSeriesId series;
                BulletShape shape;
                BulletColor color;

        public:
                BulletRuntime();
                ~BulletRuntime();

                bool addBulletEvent(BulletEvent *event);
                bool registerActiveEvent(BulletEvent *event);
                BulletEvent **allocEventList(int size);
                void checkEvents();

        private:
                BulletEvent *activeEvents[MAX_ACTIVE_EVENTS];
                BulletEvent *eventsPool[MAX_EVENTS_IN_POOL];
                int nrActive, nrEvents;
        };

}

#endif /* __TSIN_RUNTIME_BULLETRUNTIME_H__ */
